import java.util.Arrays;

public class Test{
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4};
        int[] str = arr;
        Arrays.fill(arr, -1);
        boolean flag = Arrays.equals(arr, str);
        System.out.println(flag);
        System.out.println(Arrays.toString(arr));
    }
    public static int binarySearch(int[] arr, int key) {
        int left = 0;
        int right = arr.length - 1;
        int mid;
        while(left <= right) {
            mid = (left + right) / 2;
            if(arr[mid] > key) {
                right = mid - 1;
            }else if(arr[mid] < key) {
                left = mid + 1;
            }else {
                return mid;
            }
        }
        return -1;
    }
    public static void main5(String[] args) {
        int[] arr = {1, 2, 3, 3, 3, 234, 654, 23, 4, 5, 6};
        Arrays.sort(arr);
        int key = 5;
        int ret = binarySearch(arr, key);
        System.out.println(ret);
    }
    public static void main4(String[] args) {
        int[] arr = {1, 2, 3, 4};
        int[] str = new int[10];
        System.arraycopy(arr, 0, str, 0, arr.length);
        System.out.println(Arrays.toString(str));
    }
    public static void main3(String[] args) {
        int[] arr = {1, 2, 3, 4};
        int[] str = Arrays.copyOf(arr, 7);
        System.out.println(Arrays.toString(str));
    }
    public static void main2(String[] args) {
        int[] arr = {1, 2, 3, 4};
        int[] str = Arrays.copyOfRange(arr, 0, 4);
        System.out.println(Arrays.toString(str));
    }
    public static void main1(String[] args) {
        int[] arr = {1, 2, 3, 4};
        int[] str = arr.clone();
        System.out.println(Arrays.toString(arr));
        System.out.println(Arrays.toString(str));
    }

}
